import { TErrorCode } from "../../../Message/Db/Tables/TErrorCode";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class ErrorCodeConfig
    
    export  class ErrorCodeConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (ErrorCodeConfig._instance != null) 
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TErrorCode();
                loc1.errorCode = loc2.errorCode;
                loc1.errorName = StringHelper.getString(loc2.errorName);
                loc1.errorStr = StringHelper.getString(loc2.errorStr);
                loc1.display = loc2.display;
                loc1.showServerMsg = loc2.showServerMsg;
                this._map[loc1.errorCode] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_error_code.json");
            this.write(loc1);
            return;
        }

        public getInfoByCode(arg1: int): TErrorCode
        {
            return this._map[arg1];
        }

        public getErrorStringByCode(arg1: int): string
        {
            var loc1=this._map[arg1];
            if (loc1) 
            {
                return loc1.errorStr;
            }
            return "";
        }

        public static get instance(): ErrorCodeConfig
        {
            if (ErrorCodeConfig._instance == null) 
            {
                ErrorCodeConfig._instance = new ErrorCodeConfig();
            }
            return ErrorCodeConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: ErrorCodeConfig;
    }
